<?php
/***************************************************************************/
/* SPD Nast�tten                                                           */
/* ===========                                                             */
/*                                                                         */
/* Copyright (c) 2006-2007 by Lukas Schreiner, Pascal Villmann             */
/* For more information visit: http://spd.pascalvillmann.g2host.de         */
/* Or for the ToDo List of the Project: http://luksch.freeprojekt.de/pToDo */
/*                                                                         */
/* This program is free software. You can redistribute it and/or modify    */
/* it under the terms of the GNU General Public License as published by    */
/* the Free Software Foundation; either version 0.2 of the License.        */
/***************************************************************************/
//Konfigurations-Sicherheits-Key
$config_secure_key_client = "S?a58tM!}J3gb&Z6E9{pk*Q2H1=o_Pr4Td0-7W/qCx7n2+AYf5%8?iB%zL0";
//Konfigurationsdateien einf�gen
require_once('./system/settings.inc.php');
//Markierung und Unterlinks
$home_section = "admin.php";
$home_section2 = "admin_kal2.php";
$section = "intern.php";

        /*
                Jax Calendar v1.34 - Copyright (c) 2002-2004, Andreas John aka Jack (tR)
                This program and it's moduls are Open Source in terms of General Public Licens (GPL) v2.0

                calendar.admin.php                 (admin system)
        */
        
        
    // fit if nescessary:
        define( "PATH_TO_SCRIPT", "./" );

        // global variables (have to be fitted)
        require ( dirname(__FILE__) . "/".PATH_TO_SCRIPT."settings/calendar.settings.inc.php");

        // (If exists) include localization file for the favoured language
        if ( file_exists( dirname(__FILE__) . "/".PATH_TO_SCRIPT."languages/" . $language . ".inc.php" ) )
                define( "LOC_LANG", $language ); 
        else
                define( "LOC_LANG", $default_language ); 

        require_once ( dirname(__FILE__) ."/".PATH_TO_SCRIPT."languages/" . LOC_LANG . ".inc.php" );

        if (!empty( $_SERVER["PHP_SELF"] )) $PHP_SELF = $_SERVER["PHP_SELF"];

//Administratorbereich nur ausgeben, wenn Session authentifiziert ist
//�berpr�fen ob "typid" existiert, wenn nicht, auf 0 setzen
if(!isset($_SESSION['typid'])) $_SESSION['typid'] = '0';
if(isset($_SESSION['auth']) && $_SESSION['typid'] > 0 && $_SESSION['timeout']>time()){
if(isset($_SESSION['rights']) && substr_count($_SESSION['rights'], ',11,') > 0 && substr_count($_SESSION['rights'], ',1,') > 0){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="<?php echo PATH_TO_SCRIPT; ?>css/admin.css">
<?php
include('./layout/head_meta.inc.php');
?>
  <style>
<!--
                .text { font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px;}
                .bild-text {color:#C0C0FF; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 10px;}
-->
  </style>
</head>
<body scroll="auto" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10" bgcolor="#A70D01">
  <div align="center">
  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td rowspan="3"><a href="admin_kal1.php">
      <img name="top" src="images/spdde/portal/top/t1_1_1.gif" alt="" border="0" width="141" height="70" /></a></td>
      <td><img src="images/spdde/portal/top/t1_2_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3"><img src="images/spdde/portal/top/t1_3.jpg" alt="" width="10" height="70" /></td>
      <td><img src="images/spdde/portal/top/t1_4_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3"><img src="images/spdde/portal/top/t1_5.jpg" alt="" width="10" height="70" /></td>
      <td><img src="images/spdde/portal/top/t1_6_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3"><img src="images/spdde/portal/top/t1_7.jpg" alt="" width="10" height="70" /></td>
      <td><img src="images/spdde/portal/top/t1_8_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3"><img src="images/spdde/portal/top/t1_9.jpg" alt="" width="10" height="70" /></td>
      <td><img src="images/spdde/portal/top/t1_10_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3"><img src="images/spdde/portal/top/t1_11.jpg" alt="" width="10" height="70" /></td>
      <td><img src="images/spdde/portal/top/t1_12_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3">
      <img border="0" src="images/spdde/portal/top/logo_neue_staerke.jpg" width="206" height="70"></td>
      <td><img src="images/spdde/portal/top/t1_14_1.jpg" alt="" width="49" height="13" /></td>
      <td rowspan="3"><img src="images/spdde/portal/top/t1_15.jpg" alt="" width="10" height="70" /></td>
    </tr>
    <tr>
      <td><a target="_blank" href="http://www.spd.de/">
      <img border="0" src="images/spdde/portal/top/ch_quadrat_portal_aktiv.gif" width="49" height="49"></a></td>
      <td>
      <a target="_blank" href="http://www.spd.de/servlet/PB/menu/1009322/index.php">
      <img border="0" src="images/spdde/portal/top/ch_quadrat_presse_over.gif" width="49" height="49"></a></td>
      <td>
      <a target="_blank" href="http://www.spd.de/servlet/PB/menu/1009328/index.php">
      <img border="0" src="images/spdde/portal/top/ch_quadrat_netzwerk_over.gif" width="49" height="49"></a></td>
      <td><img src="images/spdde/portal/top/t1_8_2.gif" border="0" width="49" height="49" /></td>
      <td><img src="images/spdde/portal/top/t1_10_2.jpg" alt="" width="49" height="49" /></td>
      <td><img src="images/spdde/portal/top/t1_12_2.jpg" alt="" width="49" height="49" /></td>
      <td><a target="_blank" href="http://www.spd.de/">
      <img src="images/spdde/portal/top/t1_14_2.gif" border="0" alt="" width="49" height="49" /></a></td>
    </tr>
    <tr>
      <td><img src="images/spdde/portal/top/t1_2_3.jpg" alt="" width="49" height="8" /></td>
      <td><img src="images/spdde/portal/top/t1_4_3.jpg" alt="" width="49" height="8" /></td>
      <td><img src="images/spdde/portal/top/t1_6_3.jpg" alt="" width="49" height="8" /></td>
      <td><img src="images/spdde/portal/top/t1_8_3.jpg" alt="" width="49" height="8" /></td>
      <td><img src="images/spdde/portal/top/t1_10_3.jpg" alt="" width="49" height="8" /></td>
      <td><img src="images/spdde/portal/top/t1_12_3.jpg" alt="" width="49" height="8" /></td>
      <td><img src="images/spdde/portal/top/t1_14_3.jpg" alt="" width="49" height="8" /></td>
    </tr>
  </table>

  <table border="0" cellspacing="0" cellpadding="0" width="750">
    <tr>
      <td><a href="template.php">
      <img src="images/spdde/portal/top/t2.jpg" alt="" border="0" width="150" height="22" /></a></td>
      <td width="600" valign="middle" align="right">
      </td>
    </tr>
  </table>

  <table border="0" cellspacing="0" cellpadding="0" width="750">
    <tr>
      <td rowspan="2" width="150" valign="top">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><td><a target="_blank" href="http://www.spd.de/">
            <img src="images/spdde/portal/top/t3.jpg" alt="" border="0" width="150" height="58" /></a></td></tr>
          <tr><td><img src="images/spdde/common/trans.gif" width="1" height="16" alt="" border="0" /></td></tr>
        </table>
<!-- Beginn der Navigation-->        
<?php
include('./layout/navigation/left_navi.inc.php');
?>
<!-- Ende der Navigation-->

      </td>
      <td rowspan="2" valign="top"><img src="images/spdde/common/trans.gif" width="10" height="1" alt="" border="0" /></td>
      <td width="410" valign="top" bgcolor="#FDF8EF"> 
        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FCDAD0">
          <tr>
            <td rowspan="3"><img src="images/spdde/common/trans.gif" width="8" height="1" alt="" /></td>
            <td><img src="images/spdde/common/trans.gif" width="1" height="2" alt="" /></td>
            <td rowspan="3"><img src="images/spdde/common/trans.gif" width="2" height="1" alt="" /></td>
          </tr>
          <tr><td width="400" height="14" valign="middle" class="pathnolink">
            <a href="index.php">SPD-Nast&auml;tten.de</a> &gt;
            <a href="admin.php">Administration</a> &gt;
            <a href="admin_kal1.php">Kalender</a></td></tr>
          <tr><td><img src="images/spdde/common/trans.gif" width="1" height="2" alt="" /></td></tr>
        </table>

<!-- Ueberschrift mit rotem Balken-->
        
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/spdde/common/trans.gif" width="16" height="12" alt="" /></td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td></td>
            <td width="14" valign="bottom"><img src="images/spdde/portal/basics/quadrat_rechts.gif" width="10" height="6" alt="" /></td>
            <td width="364" valign="bottom"><b>Administration</b></td>
          </tr>
          <tr>
            <td></td>
            <td><img src="images/spdde/portal/basics/quadrat_rechts.gif" width="10" height="2" alt="" /></td>
            <td></td>
          </tr>
          <tr>
            <td></td>
            <td colspan="2" bgcolor="#A70D01"><img src="images/spdde/common/trans.gif" width="1" height="2" alt="" /></td>
          </tr>
        </table>

<!-- Ueberschrift mit rotem Balken Ende-->

<!-- Inhaltstabelle-->


        <table border="0" cellspacing="0" cellpadding="0" height="335">
          <tr>
            <td rowspan="2"><img src="images/spdde/common/trans.gif" width="16" height="2" alt="" /></td>
            <td width="378" class="news"><?php

        if ( $data_source == "mysql" )
        {
                // include class for database support
                require ( PATH_TO_SCRIPT."modules/classes/mysql.inc.php" );

                // prepare objects for database access
                // list of subscribers which signed in/off
                $calendar_list           = new mysql;
                $calendar_list->name     = $calendar_file;
                $calendar_list->server   = $db_server;
                $calendar_list->login    = $db_login;
                $calendar_list->password = $db_password;
                $calendar_list->database = $db_database;
                $calendar_list->init();
                $calendar_list->order_criterion = "ORDER BY 'event_start' DESC";

                $event_list           = new mysql;
                $event_list->name     = $event_file;
                $event_list->server   = $db_server;
                $event_list->login    = $db_login;
                $event_list->password = $db_password;
                $event_list->database = $db_database;
                $event_list->init();

        }
        if ( !empty( $_GET[ "do" ] ) ) { $do = $_GET[ "do" ]; } else { $do = "list"; }
        if ( !empty( $_GET[ "id" ] ) ) { $id = $_GET[ "id" ]; } else { $id = 0; }
        if ( !empty( $_GET[ "start" ] ) ) { $start = $_GET[ "start" ]; } else { $start = 0; }

        $ox_tail = "cal_id=$cal_id&language=$language&start=$start";


        $js_cal_format = split ('[/.-]', $_js_calendar_format);

        $keys = array_keys( $js_cal_format );
        foreach ($keys as $key)
        {
                $val = $js_cal_format[$key];
                $js_date_trans[$val] = $key;        
        }

        
function _translate_date_format( $date_str, $hour, $min )
{
        global $js_date_trans;        
        
        $date_split = list ( $part[0], $part[1], $part[2]) = split ('[/.-]', $date_str );
        
        $stamp = gmmktime( $hour, $min, 0,
                        $part[ $js_date_trans["%m"] ],
                        $part[ $js_date_trans["%d"] ],
                        $part[ $js_date_trans["%Y"] ] );
                        
        
        return $stamp;
}

if ( $do == "list" )
{
        $num_dates = $calendar_list->entries();
        
        $red_data = array();
        $calendar_list->get_entry(0,$red_data);
        
        echo <<<TABLEHEAD
<table class="index" width="100%" cellpadding="0" cellspacing="0">
<tr>
        <td class="icons">&nbsp;</td>
        <td class="icons">&nbsp;</td>
        <th>{$loc_lang["date"]}</th>
        <th>{$loc_lang["event"]}</th>
</tr>
TABLEHEAD;

        $start_ofs = $start * $admin_page_break;
        $last_page = floor($num_dates / $admin_page_break)+1;
        
        if ($start < $last_page-1 )
        { 
                $start_next = $start+1;
                $link_next = "<a href=\"$PHP_SELF?$ox_tail&start=$start_next\">{$loc_lang["next_page"]}</a> &gt;";
         }
        else 
        { 
                $start_next = $start; 
                $link_next = ""; 
        }

        if ($start > 0 ) 
        { 
                $start_prev = $start-1;
                $link_prev = "&lt; <a href=\"$PHP_SELF?$ox_tail&start=$start_prev\"> {$loc_lang["prev_page"]}</a>";
        } 
        else 
        { 
                $start_prev = 0; 
                $link_prev = "";
        }

        $ii = 1;
        for ($i=1;$i<=$num_dates;$i++)
        {
                $new_id=$i-1;
                if ($i > $start_ofs)
                {
                        echo '<tr valign="top" class="line_color'.($ii%2).'">'."\n"
                        ."        <td class=\"icons\">".'<a href="'.$PHP_SELF.'?do=edit_entry&id='.$new_id."&$ox_tail".'"><IMG SRC="'.PATH_TO_SCRIPT.'images/edit_entry.gif" border="0" alt="'.$loc_lang["change"].'">'."</a></td>\n"
                        ."        <td class=\"icons\">".'<a href="'.$PHP_SELF.'?do=delete_entry&id='.$new_id."&$ox_tail".'"><IMG SRC="'.PATH_TO_SCRIPT.'images/delete_entry.gif" border="0" alt="'.$loc_lang["delete"].'">'."</a></td>\n"
                        ."        <td class=\"date\">".'<nobr>'.gmdate("d.m.Y H:i",$red_data["event_start"])."</nobr></td>\n"
                        ."        <td>".$red_data["event_title"]."</td>\n</tr>\n";
                        $ii++;
                }
                $calendar_list->get_next_entry( $red_data );
                if ($i >= $start_ofs + $admin_page_break ) break;
        }
        echo "</table>\n";
        $start++;
        echo '<div class="footline"><a href="'.$PHP_SELF."?do=new_entry&$ox_tail".'"><img src="'.PATH_TO_SCRIPT.'images/new_entry.gif" alt="'.$loc_lang["new_entry"].'" border="0">'."</a> &nbsp; {$loc_lang["new_entry"]}\n";
        echo "<div class=\"nav_page\" align=\"center\"><table><tr><td>$link_prev</td><td> | $start {$loc_lang["of_pages"]} $last_page | </td><td>$link_next</td></tr></table></div></div>";
}


if ( $do == "new_entry" )
{
        $entry1 = array();
        $entry2 = array();

        $mode = "create";
        $do = "edit_entry";
}

        function clean_quotes( $input )
        {
                $input = ereg_replace( '"', "&quot;", $input );
                return $input;
        }


if ( $do == "edit_entry" )
{
        if ( !empty( $mode ) && ($mode == "create" )) 
        {
                $nowww       = gmmktime();
                $nowww_year  = gmdate( "Y", $nowww );
                $nowww_month = gmdate( "m", $nowww );
                $nowww_day   = gmdate( "d", $nowww);

                $old_starts        = intval(gmmktime(0,0,0,$nowww_month,$nowww_day,$nowww_year));
                $old_ends          = $old_starts + 86399;
                $old_x24           = "1";
                $old_rem_start     = $old_starts;
                $old_rem_stop      = $old_starts + 86399;
                $old_status        = "";
                $old_event_title   = "";
                $old_event_key     = "";
                $old_event_description = "";
        }
        else 
        {
                $mode = "update";
                $entry1 = array();
                $calendar_list->get_entry( $id, $entry1 );
                
                $old_starts        = $entry1["event_start"];
                $old_ends          = $entry1["event_end"];
                $old_x24           = $entry1["x24"];
                $old_rem_start     = $entry1["reminder_start"];                
                $old_rem_stop      = $entry1["reminder_end"];                
                $old_status        = $entry1["status"];
                $old_event_title   = clean_quotes( $entry1["event_title"] );        
                
                $old_event_key     = $entry1["event_key"];

                $search_pattern = array(); $red_data = array();
                $search_pattern["event_key"] = $old_event_key;
                
                $pos = $event_list->find_entry( $search_pattern );
                $event_list->get_entry( $pos, $red_data );
                
                $old_event_description = ereg_replace("<br>", "\r\n", $red_data[ "event_description" ] );
                
//                $old_event_description = ( $red_data["event_description"] );
        }

        $old_start_date      = gmdate( $_local_date_format, $old_starts );        
        $old_start_hour      = gmdate( "H", $old_starts );
        $old_start_min       = gmdate( "i", $old_starts );

        $old_end_date        = gmdate( $_local_date_format, $old_ends );                
        $old_end_hour        = gmdate( "H", $old_ends );
        $old_end_min         = gmdate( "i", $old_ends );        

        $old_rem_start_date  = gmdate( $_local_date_format, $old_rem_start );        
        $old_rem_start_hour  = gmdate( "H", $old_rem_start );
        $old_rem_start_min   = gmdate( "i", $old_rem_start );

        $old_rem_stop_date   = gmdate( $_local_date_format, $old_rem_stop );        
        $old_rem_end_hour    = gmdate( "H", $old_rem_stop );
        $old_rem_end_min     = gmdate( "i", $old_rem_stop );
        
        if ($old_x24 == 1) $x24_chk = "checked"; else $x24_chk = "";

        $html_area_path = PATH_TO_SCRIPT."modules";
        $fck_editor = include('./modules/fck_editor.inc.php');
        echo <<< FORMSHEET
        <script language="Javascript1.2"><!-- // load htmlarea
                _editor_url = "$html_area_path/htmlarea/";                     // URL to htmlarea files
                var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
                if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
                if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
                if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
                if (win_ie_ver >= 5.5) {
                        document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
                        document.write(' language="Javascript1.2"></scr' + 'ipt>');  
                } else 
                { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
        // --></script> 
  
<form name="form_news" method="post" action="$PHP_SELF?do=$mode&id=$id&$ox_tail">
  <table cellspacing="0" class="input_box" align="center">
    <tr>
      <td>
        <table width="100%" border="0">
          <tr> 
            <td colspan="5">&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp; 
              <input type="hidden" name="old_event_key" value="$old_event_key">
            </td>
            <td><b>{$loc_lang["event_span"]}</b></td>
            <td>$_local_date_format</td>
            <td>hh:mm</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["start"]}:</td>
            <td> 
              <input type="text" name="new_start_date" id="f_new_start_date" value="$old_start_date" onchange="document.form_news.new_rem_start_date.value=document.form_news.new_start_date.value">
              <img src="../modules/jscalendar/img.gif" id="trigger_new_start_date" style="cursor: pointer; border: none;" title="{$loc_lang["date_select"]}"></td>
            <td> 
              <input type="text" name="new_start_hour" maxlength="2" size="3" value="$old_start_hour">
              : 
              <input type="text" name="new_start_min" maxlength="2" size="3" value="$old_start_min">
            </td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["end"]}:</td>
            <td> 
              <input type="text" name="new_end_date" id="f_new_end_date" value="$old_end_date" onchange="document.form_news.new_rem_end_date.value=document.form_news.new_end_date.value">
              <img src="../modules/jscalendar/img.gif" id="trigger_new_end_date" style="cursor: pointer; border: none;" title="{$loc_lang["date_select"]}"></td>
            <td> 
              <input type="text" name="new_end_hour" maxlength="2" size="3" value="$old_end_hour">
              : 
              <input type="text" name="new_end_min" maxlength="2" size="3" value="$old_end_min">
            </td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["whole_day"]}: </td>
            <td colspan="3"> 
              <input type="checkbox" name="new_x24" value="1" $x24_chk>
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["state"]}:</td>
            <td colspan="3"> 
              <input type="text" name="new_status" maxlength="100" size="50" value="$old_status">&nbsp;<a href="../modules/pic_selector.php?image_list=categories" onclick="JavaScript: window.open( this.href,'PicSelector', 'width=400,height=280,left=100,top=50,resizable=yes');" target="PicSelector"><img src="../images/sel_img.gif" width="24" height="24" border="0"></a>
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["title"]}:</td>
            <td colspan="3"> 
              <input type="text" name="new_event_title" size="50" value="$old_event_title">
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["detailed_info"]}:</td>
            <td colspan="3"> 
<textarea name="new_event_description" cols="40" rows="5">$old_event_description</textarea>
            </td>
          </tr>
          <tr> 
            <td colspan="5">&nbsp;</td>
          </tr>
          <tr> 
            <td colspan="5"> 
              <div align="center"> 
                <input type="submit" name="sendbutton" value="{$loc_lang["change"]}">&nbsp;<input type="button" name="cancel" onClick="javascript:history.back();" value="Abbrechen">
              </div>
            </td>
          </tr>
          <tr> 
            <td colspan="5">&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><b>{$loc_lang["display_span"]}</b></td>
            <td>$_local_date_format</td>
            <td>hh:mm</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["start"]}:</td>
            <td> 
              <input type="text" name="new_rem_start_date" id="f_new_rem_start_date" value="$old_rem_start_date">
              <img src="../modules/jscalendar/img.gif" id="trigger_new_rem_start_date" style="cursor: pointer; border: none;" title="{$loc_lang["date_select"]}"></td>
            <td> 
              <input type="text" name="new_rem_start_hour" maxlength="2" size="3" value="$old_rem_start_hour">
              : 
              <input type="text" name="new_rem_start_min" maxlength="2" size="3" value="$old_rem_start_min">
            </td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>{$loc_lang["end"]}:</td>
            <td> 
              <input type="text" name="new_rem_end_date" id="f_new_rem_end_date" value="$old_rem_stop_date">
              <img src="../modules/jscalendar/img.gif" id="trigger_new_rem_end_date" style="cursor: pointer; border: none;" title="{$loc_lang["date_select"]}"></td>
            <td> 
              <input type="text" name="new_rem_end_hour" maxlength="2" size="3" value="$old_rem_end_hour">
              : 
              <input type="text" name="new_rem_end_min" maxlength="2" size="3" value="$old_rem_end_min">
            </td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td colspan="5">&nbsp;</td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>

        <script type="text/javascript">
        Calendar.setup({
                inputField     :    "f_new_start_date",         
                ifFormat       :    "$_js_calendar_format",     
                button         :    "trigger_new_start_date",   
                singleClick    :    false                       
            });
        
        Calendar.setup({
                inputField     :    "f_new_end_date",         
                ifFormat       :    "$_js_calendar_format",    
                button         :    "trigger_new_end_date",   
                singleClick    :    false                  
            });
        
        Calendar.setup({
                inputField     :    "f_new_rem_start_date",
                ifFormat       :    "$_js_calendar_format",
                button         :    "trigger_new_rem_start_date",
                singleClick    :    false
            });
                 
        Calendar.setup({
                inputField     :    "f_new_rem_end_date",
                ifFormat       :    "$_js_calendar_format",
                button         :    "trigger_new_rem_end_date",
                singleClick    :    false
            });  
    
    </script>    

<script language="JavaScript1.2" defer>
        editor_generate('new_event_description');
</script>
FORMSHEET;
}


if ( $do == "delete_entry" )
{
        echo "<p>{$loc_lang["delete_entry_confrm"]}</p>";
        echo "<p><a href=\"$PHP_SELF?do=remove_entry&id=$id&$ox_tail\">{$loc_lang["yes"]}</a></p>";
        echo "<p><a href=\"$PHP_SELF?$ox_tail\">{$loc_lang["no"]}</a></p><p>&nbsp;</p>";

        exit;
}

if ( $do == "remove_entry" )
{
        $entry1 = array();
        $calendar_list->get_entry( $id, $entry1 );
        $old_event_key = $entry1["event_key"];
        
        $calendar_list->delete( $id );

        $search_pattern = array();
        $search_pattern["event_key"] = $old_event_key;
                
        $pos = $event_list->find_entry( $search_pattern );
        $event_list->delete( $pos );

        echo '<meta http-equiv="refresh" content="0;URL='.$PHP_SELF."?do=list&$ox_tail".'">';
        exit;
}


if ( $do == "create" || $do == "update" )
{
        
        $old_event_key = $_POST[ "old_event_key" ];

        $new_event_start    = _translate_date_format( $_POST["new_start_date"], $_POST["new_start_hour"], $_POST["new_start_min"] );

        $new_event_end      = _translate_date_format( $_POST["new_end_date"], $_POST["new_end_hour"], $_POST["new_end_min"] );
        $new_reminder_start = _translate_date_format( $_POST["new_rem_start_date"], $_POST["new_rem_start_hour"], $_POST["new_rem_start_min"] );
        $new_reminder_end   = _translate_date_format( $_POST["new_rem_end_date"], $_POST["new_rem_end_hour"], $_POST["new_rem_end_min"] );
        
        if ( empty( $_POST[ "new_x24" ] ) ) $new_x24 = 0; else $new_x24 = $_POST[ "new_x24" ];

        $new_status         = $_POST[ "new_status" ];
        $new_event_title    =  clean_quotes( $_POST[ "new_event_title" ] );
        
        if ($data_source == "csvfile") $new_event_description = ereg_replace("(\r\n|\n|\r)", "<br>", $_POST[ "new_event_description" ] );
        else $new_event_description = $_POST[ "new_event_description" ];
        
        $new_event_key = md5( strval( $new_event_start . $new_event_end . $new_event_title ) );
}


if ( $do == "update" )
{
        $calendar_list->delete( $id );

        $search_pattern = array();
        $search_pattern["event_key"] = $old_event_key;
                
        $pos = $event_list->find_entry( $search_pattern );
        $event_list->delete( $pos );
                
        $do = "create";
}


if ( $do == "create" )
{
        $num_dates = $calendar_list->entries();
        
        $red_data = array();
        $calendar_list->get_entry(0,$red_data);

        $i = 0;
        while ( $i<$num_dates && $new_event_start <= $red_data["event_start"] )
        {
                $calendar_list->get_next_entry( $red_data );        
                $i++;
        }
        
        $to_cal = array();
        $to_cal["event_start"]    = $new_event_start;
        $to_cal["event_end"]      = $new_event_end;
        $to_cal["x24"]            = $new_x24;
        $to_cal["reminder_start"] = $new_reminder_start;
        $to_cal["reminder_end"]   = $new_reminder_end;
        $to_cal["status"]         = $new_status;
        $to_cal["event_title"]    = $new_event_title;
        $to_cal["event_key"]      = $new_event_key;                
        
        $calendar_list->insert( $i, $to_cal );
        
        $to_evt = array();
        $to_evt["event_key"]         = $new_event_key;
        $to_evt["event_description"] = $new_event_description;
        
        $event_list->append( $to_evt );
        
        echo '<meta http-equiv="refresh" content="0;URL='.$PHP_SELF."?do=list&$ox_tail".'">';
        exit;
        
}

?>

<div class="admin">
<!-- Please don't remove the link to the author's website!!! -->
<p class="author_info">Jax Calendar v1.34, by Jack (tR), <a href="http://www.jtr.de/scripting/php">www.jtr.de</a></p>
</div></td>
          </tr>
          <tr>
            <td width="378" height="19"> 
              &nbsp;</td>
          </tr>
        </table>
        
        
<!-- Inhaltstabelle Ende-->



      </td>
      <td rowspan="2"><img src="images/spdde/common/trans.gif" width="10" height="1" alt="" border="0" /></td>
      <td rowspan="2" width="170" valign="top" bgcolor="#FDF8EF">
        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FCDAD0">
          <tr><td><img src="images/spdde/common/trans.gif" width="170" height="18" alt="" /></td></tr>
        </table>

        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/spdde/common/trans.gif" width="12" height="25" alt="" /></td>
            <td></td>
          </tr>
          <tr>
            <td></td>
            <td><img src="images/spdde/portal/basics/linie_2nd.gif" width="146" height="1" vspace="2" alt="" /></td>
          </tr>
          <tr>
            <td></td>
            <td width="146"><span class="navi4thnolink">Interaktiv</span></td>
          </tr>
        </table>


<!-- Eintrag Interaktiv Anfang -->        
        <?php
include('./layout/navigation/right_navi.inc.php');
?>
<!-- Eintrag Interaktiv Ende -->
<?php
include('./layout/right.inc.php');
?>
</td>
    </tr>
    <tr>  <!-- hier beginnt der footer -->
      <td width="410" valign="bottom" bgcolor="#FDF8EF">
        <table border="0" cellspacing="0" cellpadding="0" bgcolor="#FDF8EF">
          <tr>
            <td rowspan="4"><img src="images/spdde/common/trans.gif" width="16" height="1" alt="" /></td>
            <td><img src="images/spdde/common/trans.gif" width="1" height="10" alt="" /></td>
          </tr>
          <tr>
            <td valign="top"><a href="#top">
            <img src="images/spdde/portal/basics/hoch.gif" border="0" alt="" width="8" height="8" /></a></td>
          </tr>
          <tr>
            <td bgcolor="#A70D01"><img src="images/spdde/common/trans.gif" width="378" height="2" alt="" /></td>
          </tr>
          <tr>
            <td height="16" valign="middle" align="right">&copy; <?php echo $global_copy . " - " . $global_years; ?> &nbsp;<a href="impressum.php">Impressum</a></td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

  </div>
</body>
</html>
<?php
//Hier Ende des authentifizierten Bereiches
}else{
header('Location: admin_false.php');
exit;
}
}else{
header('Location: false.php');
}
?>